<?php
/**
 * User: zy
 * Date: 2018-06-25 14:10:30
 * @Description: PMS 合同操作日志相关
 */
class SupplierContractLog extends Eloquent
{
    protected $table = "supplier_contract_logs";
    
    /**
     * @Author:          zk
     * @DateTime:        18-6-25 下午3:59
     * @var array  操作类型数组
     */
    public static $action_type_arr = [
        '1' => '新建合同',
        '2' => '编辑合同',
        '3' => '上传附件',
        '4' => '删除附件',
    ];
    
    /**
     * @Author:          zk
     * @DateTime:        18-6-25 下午3:59
     * @Description:     合同操作日志新增
     * @param int $supplier_id  供应商id
     * @param int $contract_id  合同id
     * @param int $action_type  操作类型 (1:新建合同;2:编辑合同;3:上传附件;4:删除附件;)
     * @param int $admin_id     管理员id
     * @return boolean
     */
    public static function writeContractLog($supplier_id, $contract_id, $action_type, $admin_id) {
        $scl = new SupplierContractLog();
        $scl->supplier_id = $supplier_id;
        $scl->contract_id = $contract_id;
        $scl->action_type = $action_type;
        $scl->created_at = date('Y-m-d H:i:s', time());
        $scl->created_by = $admin_id;
        $res = $scl->save();
        return $res;
    }
    
}